<?php 
## include required files
/*******************************/
require_once '../model/analytics.php';
/*******************************/

## Create Objects
/*******************************/
$analyticObj = new Model_Analytics();
/*******************************/
if(isset($_POST['addfaq_btn'])) {
	## apply PHP validation for required filed
	if(trim($_POST['analytics_name']) != '' && trim($_POST['analytics_code']) != '') {
		$anArray = array();
		extract($_POST);
		$anArray['analytics_name']   = return_post_value($analytics_name);
		$anArray['analytics_code']   = $analytics_code;
		$anArray['status']   = 1;
		$analyticObj->addAnalytics($anArray);
		$_SESSION['msg'] = "<div class='success_msg'><span>Analytics added successfully</span></div>";
		header('location:'.SITE_URL.'/admin/home.php?q=analytics');
		exit;
	} else { // php validation else
		$_SESSION['msg'] = '<div class="error_msg"><span>Please enter analytics details</span></div>';
	}
	// main if closed
}

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Set active class variable for left menu
$smarty->assign('activeclass', 'analytics');
$smarty->assign('mainmenu', '6');
## Unset all the objects created which are on this page
unset($analyticObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'analytics/addanalytics.tpl');
unset($smarty);
?>